package com.wlyuan.open.scanner.controller;

import com.wlyuan.open.scanner.service.ScannerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lijing
 * @description
 */
@Api(tags = "全量扫描")
@Validated
@RequestMapping("/scanner")
@RestController
@Slf4j
public class ScannerController {
    @Autowired
    private ScannerService scannerService;

    @ApiOperation("租户/用户全量扫描，顺序 租户->用户->租户邀请关系")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "参数：公司租户,个体司机租户,用户,租户邀请关系", paramType = "query", allowMultiple = true)
    })
    @PostMapping("/scannerTenant")
    public void scannerTenant(String name) {
        name = StringUtils.isBlank(name) ? "公司租户,个体司机租户,用户,租户邀请关系" : name;
        scannerService.scanner(name);
    }

    @ApiOperation("司机,车辆,客户,承运方,承运方邀请关系,合同全量扫描")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "参数：司机,车辆,客户,承运方,合同", paramType = "query", allowMultiple = true)
    })
    @PostMapping("/scannerBasic")
    public void scannerBasic(String name) {
        name = StringUtils.isBlank(name) ? "司机,车辆,客户,承运方,承运方邀请关系,合同" : name;
        scannerService.scanner(name);
    }

    @ApiOperation("收货方全量扫描")
    @PostMapping("/scannerConsignee")
    public void scannerConsignee() {
        scannerService.scannerConsignee();
    }

    @ApiOperation("物品全量扫描")
    @PostMapping("/scannerGoods")
    public void scannerGoods() {
        scannerService.scannerGoods();
    }

    @ApiOperation("订单全量扫描")
    @PostMapping("/scannerOrder")
    public void scannerOrder() {
        scannerService.scannerOrder();
    }

    @ApiOperation("运单全量扫描")
    @PostMapping("/scannerTransport")
    public void scannerTransport() {
        scannerService.scannerTransport();
    }

    @ApiOperation("运单关系全量扫描")
    @PostMapping("/scannerTransportRelation")
    public void scannerTransportRelation() {
        scannerService.scannerTransportRelation();
    }

    @ApiOperation("拼车单全量扫描")
    @PostMapping("/scannerCombine")
    public void scannerCombine() {
        scannerService.scannerCombine();
    }

    @ApiOperation("合约全量扫描")
    @PostMapping("/scannerTemplate")
    public void scannerTemplate() {
        scannerService.scannerTemplate();
    }

    @ApiOperation("报价全量扫描")
    @PostMapping("/scannerQuotation")
    public void scannerQuotation() {
        scannerService.scannerQuotation();
    }

    @ApiOperation("对账单全量扫描")
    @PostMapping("/scannerBill")
    public void scannerBill() {
        scannerService.syncBill();
    }

    @ApiOperation("收付款全量扫描")
    @PostMapping("/scannerPay")
    public void scannerPay() {
        scannerService.syncPay();
    }

    @ApiOperation("收付款按类型全量扫描")
    @PostMapping("/scannerPayType")
    public void scannerPayType(@RequestParam("type") Integer type) {
        scannerService.syncPayType(type);
    }

    @ApiOperation("脱普扩展数据全量扫描")
    @PostMapping("/scannerTopExt")
    public void scannerTopExt() {
        scannerService.syncTopExtension();
    }

    @ApiOperation("合单报价全量扫描")
    @PostMapping("/syncCombineQuotation")
    public void syncCombineQuotation() {
        scannerService.syncCombineQuotation();
    }

}
